﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Control_Area : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindData();
    }

    protected void BindData()
    {
        ddlProvince.DataSource = new MatchIns.BLL.TB_Province().GetList();
        ddlProvince.DataTextField = "ProvinceName";
        ddlProvince.DataValueField = "ProvinceID";
        ddlProvince.DataBind();
        ddlProvince.Items.Insert(0,new ListItem("省份...","0"));
    }

    /// <summary>
    /// 省份id
    /// </summary>
    public int ProviceId
    {
        get
        {
            int tmp;
            int.TryParse(ddlProvince.SelectedValue, out tmp);
            return tmp;
        }
    }

    /// <summary>
    /// 城市id
    /// </summary>
    public int CityId
    {
        get
        {
            int tmp;
            //int.TryParse(ddlCity.SelectedValue, out tmp);
            int.TryParse(Request.Form["cityid"], out tmp);
            return tmp;
        }
    }

    /// <summary>
    /// 区县id
    /// </summary>
    public int DistrictId
    {
        get
        {
            int tmp;
            int.TryParse(Request.Form["districtid"], out tmp);
            return tmp;
        }
    }

    /// <summary>
    /// 是否执行验证
    /// </summary>
    public bool Validate
    {
        set
        {
            this.cvddlProvince.Enabled = false;
            this.cvddlCity.Enabled = false;
            this.cvddlDistrict.Enabled = false;
        }
    }
}
